package com.production.CoursePlatform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.production.CoursePlatform.entity.Student;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface StudentMapper{

    // 根据 sID 查询单个 Student 记录
    @Select("SELECT * FROM student WHERE s_id = #{sID}")
    Student findBySID(@Param("sID") String sID);

    // 插入新的 Student 记录
    @Insert("INSERT INTO student (s_id, s_name, s_gender, s_grade, s_class) " +
            "VALUES (#{sID}, #{sName}, #{sGender}, #{sGrade}, #{sClass})")
    int insertStudent(Student student);

    // 更新 Student 记录
    @Update("UPDATE student SET s_name = #{sName}, s_gender = #{sGender}, s_grade = #{sGrade}, s_class = #{sClass} WHERE s_id = #{sID}")
    int updateStudent(Student student);

    // 删除 Student 记录
    @Delete("DELETE FROM student WHERE s_id = #{sID}")
    int deleteBySID(@Param("sID") String sID);
}
